<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false"%>
<c:set var="rootPath" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>城市信息</title>
<link href="${rootPath}/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css"
	rel="stylesheet" type="text/css" />
<link href="${rootPath}/fare/lib/ligerUI/skins/ligerui-icons.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="${rootPath}/js/jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript"
	src="${rootPath}/fare/lib/ligerUI/js/core/base.js"></script>
<script type="text/javascript"
	src="${rootPath}/fare/lib/ligerUI/js/ligerui.min.js"></script>
<script type="text/javascript">
	var grid;
	$(function() {
		var toolbars = {
				items : [
							{
								text : '增加',
								click : itemclick,
								icon : 'add'
							},
							{
								line : true
							} ,
							{
								text : '修改',
								click : itemclick,
								icon : 'modify'
							},
							{
								line : true
							},
							{
								text : '删除',
								click : itemclick,
								img : '${rootPath}/fare/js/ligerUI/skins/icons/delete.gif'
							} ,{
								text : '创建选择框数据',
								img : "${pageContext.request.contextPath}/images/icons/toolbar/page_edit.gif",
								click :  function(item) {
									createScript();
								//	createSingleScript();
								}
							}  ]
				};
		 grid = $("#maingrid").ligerGrid(
				{
					columns : [ {
						display : '编码',
						name : 'code',
						align : 'center',
						width : 50
					}, {
						display : '名称',
						name : 'name',
						align : 'center',
						width : 80
					},{
						display : '类型',
						name : 'treeTypeDesc',
						width : 100
					},{
						display : '别名',
						name : 'aliasName',
						width : 150
					},{
						display : '英文简称',
						name : 'nameSpellInitials',
						width : 100
					},{
						display : '英文名称',
						name : 'nameSpell',
						width : 150
					},{
						display : '热门等级',
						name : 'hotLevel',
						width : 80
					},{
						display : '创建时间',
						name : 'createDate',
						width : 180
					}],
					  dataAction: 'server',toolbar: toolbars,
			          url: '${rootPath}/cityManage/listJSON.action?pid=${pid}&treeType=${treeType}', 
			          sortName: 'name',
			          width: '98%', height: '100%', checkbox: true,
			          pageParmName:"page",
			          pageSizeOptions:[10,20,50],
			          pagesizeParmName:"pagesize",
			          rowHeight:23,
			          rownumbers:true,
			          isScroll:true,
			          sortnameParmName:"sortName",
			          sortorderParmName:"sortOrder",
			          checkbox:true,
			          pageSize: 10,
			          onToNext:next,//条件查询方法
			         
				});
	 function next(){
		 grid.setOptions();
	}
		function itemclick(item){
			   var row = grid.getSelectedRow(); 
		       if(item.text == '增加'){
		    	  // parent.f_addTab("editCabin", '新增舱位', '${rootPath}/plane/cabinedit/edit.action?id=');
		    	   dlog=$.ligerDialog.open({ url: "${rootPath}/cityManage/edit.action?pid=${pid}&id=", height: 480, width: 690,title:"新增舱位", isResize: true});	
		        } else if(item.text == '修改'){
		        	if(row == null){
		              	alert("请先选择一条数据!");
		              	return ;
		           }
		        	dlog=$.ligerDialog.open({ url: "${rootPath}/cityManage/edit.action?pid=${pid}&id="+row.id, height: 480, width: 690,title:"编辑舱位", isResize: true});	
		        	//parent.f_addTab("editCabin", '编辑舱位', '${rootPath}/plane/cabinedit/edit.action?id=' + row.id);
		        }else if(item.text == '删除'){
		    	   if(row == null){
		              	alert("请先选择一条数据!");
		              	return ;
		           }
		    	   $.ligerDialog.confirm('您确定要删除选择的记录?', function (yes) {
		    		   $.ajax({
		    			   type: "POST",
		    			   url: "${rootPath}/plane/cabindelete/delete.action",
		    			   data: getSelectedRowDatas(),
		    			   dataType:"json",
		    			   success: function(data){
		    				   if(data && data.hasOk){
		    					   $.ligerDialog.success("操作成功!", '提示信息',function(){
		    						   grid.loadData();
		    					   });
		    					  
		    				   }
		    		       }
		    			});
		    	   });
		       }
		}
	});
	
	function createScript(){
		$.ajax({
			   type: "POST",
			   url: "${rootPath}/cityManage/creatCtityScript.action",
			   dataType:"json",
			   success: function(msg){
			     alert(msg.msg);
			   }
			});
	}
	function createSingleScript(){
		var item = $("input[name='sourceId']:checked").val();
	/* 	if(typeof(item) == "undefined"){
			alert("请选择航空公司!");
		}else{ */
			$.ajax({
				   type: "POST",
				   url: "${rootPath}/createCityScriptAction!getCityInfoByCompany.action",
				   data: "sourceId="+item,
				   dataType:"text",
				   success: function(msg){
					   alert(msg);
				   }
			});
		/* } */
		
	}
</script>

</head>
<body style="overflow-x: hidden; padding: 2px;">
	<div class="l-clear"></div>
	<div id="maingrid"></div>
</body>
</html>